#include "EnvironmentalObject.h"
#include "GameplayState.h"
#include "../SGD Wrappers/SGD_Event.h"



EnvironmentalObject::EnvironmentalObject() : Listener(this)
{

}
EnvironmentalObject::~EnvironmentalObject()
{
	UnregisterFromEvent(event.c_str());
}

void EnvironmentalObject::HandleCollision(const IBase* pOther)
{
	if (pOther->GetType() == OBJ_PLAYER)
	{
		SGD::Event* msg = new SGD::Event(event.c_str(), (Player*)pOther );
		msg->QueueEvent();
		msg = nullptr;
	}
	else if (pOther->GetType() == OBJ_GUARD 
		|| pOther->GetType() == OBJ_OFFICER
		|| pOther->GetType() == OBJ_WORKER 
		|| pOther->GetType() == OBJ_ELITE_GUARD)
	{
		if (event == "ALARM_OFF")
		{
			SGD::Event* msg = new SGD::Event("ALARM_TRIGGER");
			msg->QueueEvent();
			msg = nullptr;
		}
	}

	
	

}

/*virtual*/ SGD::Rectangle EnvironmentalObject::GetRect(void) const
{
	SGD::Point renderPos = SGD::Point(m_ptPosition.x

		- GameplayState::GetInstance()->GetCamera()->GetPosition().x,
		m_ptPosition.y

		- GameplayState::GetInstance()->GetCamera()->GetPosition().y);

	return SGD::Rectangle({ renderPos, m_szSize });
}
